home *** CD-ROM | disk | FTP | other *** search
- ----------------------
- Tiny BASIC Interpreter
- ----------------------
-
- This is a simple BASIC interpreter written in ACE BASIC. It is loosely based
- upon the original Dr Dobbs version and should be considered a toy version.
-
- The language supports numeric variables and string literals. All numbers
- are single-precision fixed-point values.
-
- The following commands are implemented:
-
- CLS
- GOTO <line>
- IF <expr> THEN <statement> [ELSE <statement>]
- INPUT <variable>
- LET <variable>=<expr>
- LIST
- LOAD <string-literal>
- NEW
- PRINT <expr> | <string-literal> [,..]
- RUN
- SAVE <string-literal>
- STOP
-
- where <expr> is a numeric expression, <string-literal> is a double-quote
- enclosed string of characters, and <line> is a program line number, where
- only the integer portion of the number is used.
-
- Multi-statements are supported by Tiny BASIC (ie: statements separated by
- colons).
-
- There are only 26 variables, corresponding to the letters of the alphabet.
- Although variable names can have multiple letters, names beginning with
- the same letter are identical variables (eg: F is the same as FRED).
-
- Tiny BASIC supports the following intrinsic functions:
-
- SIN(n)
- COS(n)
- TAN(n)
- LOG(n)
- SQR(n)
- FIX(n)
- INT(n)
- RND
-
- where n is a number. FIX returns the integer portion of a number while
- INT (the same as ACE's CLNG) rounds its argument.
-
- Operators in order of precedence are:
-
- ^ exponentiation
- - unary negation
- * / multiplication and division
- + - addition and subtraction
- = < > <= >= <> relational operators
-
- Grouping terms with parentheses alters the precedence of operations.
-
- The interpreter is slow and limited in functionality, but it's interesting to
- note that Tiny BASIC has some features which ACE does not:
-
- - run-time error messages
- - division-by-zero trapping
-
- These are much simpler to implement in a simple interpreter like TinyBASIC
- but are also planned for ACE.
-
- Error messages are as follows:
-
- 1. Division by zero
- 2. Syntax error
- 3. Stack overflow
- 4. Stack underflow
- 5. Line out of range 1..maxlines
- 6. Line does not exist
- 7. Out of memory
- 8. Can't open file for writing
- 9. File not found
-
- Memory allocation for program lines is dynamic so as not to hog memory
- unnecessarily, however there is still a limit to the number of lines
- allowed (maxlines is currently set to 1000 but this can easily be changed).
-
- Tiny BASIC was written for two reasons:
-
- - As a test of the ACE Amiga BASIC compiler (which has far more
- features than Tiny BASIC).
-
- - It was a fun thing to do :-).
-
- Although often loathe to admit it, many programmers got their start by using
- interpreters not much more complex than Tiny BASIC, but a quick glance at the
- ACE documents will show how far BASIC has come in the last several years. And
- it's still going strong.
-
- Anyway, reminisce and enjoy!
-
- David Benn
- February 1993
-